﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace MyEvent
{
    class Program
    {
        static void Main(string[] args)
        {
            Student student = new Student();
            List<Book> books = new List<Book>
            {
                new Book{BookId=1,BookName="语文"},
                new Book{BookId=2,BookName="数学"},
                new Book{BookId=3,BookName="英语"},
                new Book{BookId=4,BookName="地理"},
                new Book{BookId=5,BookName="历史"},

            };
            books.ForEach(a => Console.WriteLine(a.ToString()));
            Console.WriteLine("请输入书籍ID购买");
            while (true)
            {
                int resule;
                if (int.TryParse(Console.ReadLine(), out resule))
                {
                    var pro = books.Where(a =>a.BookId == resule).FirstOrDefault();
                    if (pro != null)
                    {
                        student.NoBook(pro);
                    }
                    else
                    {
                        Console.WriteLine("没有这个ID");
                    }
                }
                else
                {
                    Console.WriteLine("请输入数字");
                }

            }
        }
        public static void Prosucceed(Book book) => Console.WriteLine($"购买了：{book.BookName}");
        public static void ProAll(Book book) => Console.WriteLine($"{book.BookName},数量剩余：{book.BookCount}");
        public static void ProNoThing(Book book) => Console.WriteLine($"{book.BookName}的数量为空!");
    }
}
